package com.threa;

import java.io.IOException;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;

/**
 * jdk 1.5 线程优化
 * 
 * @author DingQingbo
 * 
 */
public class ThreadD {
	public static void main(String[] args) throws IOException {

		// 1
		// System.out.println(ThreadD.class.getName());
		// System.out.println(new ThreadD().getClass().getName());

		// final ExecutorService
		// executorService=Executors.newSingleThreadExecutor();
		// executorService.execute(new Runnable() {
		//
		// @Override
		// public void run() {
		// System.out.println(executorService.getClass().getName());
		//
		// }
		// });
		// //2
		// final ExecutorService
		// executorService2=Executors.newCachedThreadPool();
		// executorService2.execute(new Runnable() {
		//
		// @Override
		// public void run() {
		//
		// System.out.println(executorService2.getClass().getName());
		// }
		// });
		//

		// ThreadPoolExecutor executor=new ThreadPoolExecutor();

		// //3
		// final ScheduledExecutorService
		// executorService3=Executors.newScheduledThreadPool(10);
		// executorService3.execute(new Runnable() {
		//
		// @Override
		// public void run() {
		//
		// System.out.println(executorService3.getClass().getName());
		// }
		// });

		// 4多线程定时任务
		//
		// final ScheduledExecutorService
		// executorService3=Executors.newScheduledThreadPool(10);
		//
		// executorService3.scheduleAtFixedRate(new Runnable() {
		//
		// @Override
		// public void run() {
		// System.out.println("123");
		//
		// }
		// }, 2, 2, TimeUnit.SECONDS);
		//
		//

		// 5
		new Thread(new Runnable() {

			@Override
			public void run() {
				System.out.println("123");

			}
		}).start();
		// 6
//		Executors.newCachedThreadPool();
//		 Executors.newFixedThreadPool;

	}

}
